package com.yunianvh.webrtc_compose_demo.webrtc

import org.webrtc.Logging
import org.webrtc.VideoFrame
import org.webrtc.VideoSink

/**
 * Created by 玉念聿辉.
 * User: 吴明辉
 * Date: 2023/5/9
 * Time: 15:43
 */
class ProxyVideoSink : VideoSink {
    private var target: VideoSink? = null

    @Synchronized
    override fun onFrame(frame: VideoFrame?) {
        if (target == null) {
            Logging.d(TAG, "Dropping frame in proxy because target is null.")
            return
        }
        target!!.onFrame(frame)
    }

    @Synchronized
    fun setTarget(target: VideoSink?) {
        this.target = target
    }

    companion object {
        private const val TAG = "dds_ProxyVideoSink"
    }
}